import request from '@/utils/http'

interface BaseResult<T = any> {
  code: string
  msg: string
  data: T
}

export class LoginMethod {
  // 发送手机验证码
  static sendSmsCode(params: object) {
    return request.get<BaseResult>({
      url: '/sms/sendCode',
      params
    })
  }

  // 手机验证码登录
  static smsCodeLogin(params: object) {
    return request.get<BaseResult>({
      url: '/auth/login/sms',
      params
    })
  }

  // 微信跳转
  static getWXQrCode(params: object) {
    return request.get<BaseResult>({
      url: '/auth/generateQr',
      params
    })
  }
  // 微信扫码登录
  static wxScanCodeLogin(data: object) {
    return request.get<BaseResult>({
      url: '/auth/passport',
      params: data
    })
  }

  // 微信扫码授权
  static wxAuthorization(data: object) {
    return request.get<BaseResult>({
      url: '/auth/generateQrV2',
      params: data
    })
  }

  // 授权回调
  static getAuthorizationStatus(data: object) {
    return request.post<BaseResult>({
      url: '/auth/getUserOpenId',
      data
    })
  }

  // 忘记密码
  static forgotPassword(data: object) {
    return request.post<BaseResult>({
      url: '/auth/updatePassword/sms',
      data
    })
  }

  // 获取当前配置的隐私协议
  static privacyPolicy() {
    return request.get<BaseResult>({
      url: '/auth/getLoginConfig'
    })
  }

  // 手机号验证码校验
  static verification(data: object) {
    return request.get<BaseResult>({
      url: '/sms/verificat',
      params: data
    })
  }
}
